<template>
  <div>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="学科名称" prop="subjectName">
          <el-input v-model="ruleForm.subjectName"></el-input>
        </el-form-item>
        <el-form-item label="是否显示">
          <el-switch
            v-model="ruleForm.isFrontDisplay"
            active-color="#13ce66"
            inactive-color="#ff4949"
            :inactive-value="0"
            :active-value="1"
          ></el-switch>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { update } from '../../../api/hmmm/subjects'
export default {
  name: '',
  props: {},
  components: {},
  data () {
    return {
      dialogVisible: false,
      rules: {
        subjectName: { required: true, message: '请输入活动名称', trigger: 'blur' }
      },
      id: 0,
      ruleForm: {
        subjectName: '',
        isFrontDisplay: 0
      }
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    handleClose (done) {
      done()
    },
    simple (row) {
      // console.log(row)
      this.ruleForm.subjectName = row.subjectName
      this.ruleForm.isFrontDisplay = row.isFrontDisplay
      this.id = row.id
    },
    submit () {
      this.$refs.ruleForm.validate(async (valid) => {
        if (valid) {
          await update({
            subjectName: this.ruleForm.subjectName,
            isFrontDisplay: this.ruleForm.isFrontDisplay,
            id: this.id
          })
          this.dialogVisible = false
          this.$message.success('修改成功')
          this.$emit('refrsh')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }

  }
}

</script>

<style lang="scss" scoped>
</style>
